<template>
  <el-radio-group v-model="radio">
    <el-row>
      <el-col v-for="item,index in value" :key="index">
        <el-radio :label="item.code" @change="radiofn">{{ item.code }}</el-radio>
        <el-input v-model="value[index].title" style="width:300px" />
        <span class="uppic">
          <UploadImage v-model="value[index].img" />
        </span>
      </el-col>
    </el-row>

  </el-radio-group>
</template>
<script>
import UploadImage from './uploadimage.vue'
export default {
  name: 'Selectitem',
  components: {
    UploadImage
  },
  props: {
    abcd: {
      type: [Array],
      required: true
    },
    value: {
      type: [Array],
      required: true
    }
  },
  data() {
    return {
      radio: '',
      img: ''

    }
  },
  watch: {
    value: {
      handler(n, o) {
        n.forEach((i) => {
          if (i.isRight === 1) {
            this.radio = i.code
          }
        })
      }
    }
  },
  mounted() {
    this.abcd.forEach((item, index) => {
      this.value[index].code = item
    })
  },
  created() {

  },

  methods: {
    radiofn(val) {
      this.value.forEach((item) => {
        item.isRight = 0
      })
      this.abcd.forEach((item, index) => {
        if (item === val) {
          this.value[index].isRight = 1
        }
      })
    }
  }
}
</script>
<style lang="scss" scoped>
.uppic{
  position: relative;
  ::v-deep .el-upload--picture-card{
  position: absolute;
  left: 480px;
  top: -43px;
    width:100px;
    height: 50px;
    position: relative;
    .el-icon-circle-close{
      position: absolute;
      right: -5px;
      top: -5px;
      font-size: 14px;
    }

    .pic{

      font-size: 15px;
      position: absolute;
      left: 20px;
      top: -46px;
    }
  }
  .avatar{
    width: 200px;
    height: 100px;
  }

}

</style>
